package com.test.controller;


import com.test.common.BaseResponse;
import com.test.common.ErrorCode;
import com.test.common.ResultUtils;
import com.test.model.pojo.SingleQuestion;
import com.test.service.SingleQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ss")
public class SingleQuestionController {

    @Autowired
    SingleQuestionService singleQuestionService;


    @GetMapping("/getQuestionById/{id}")
    public BaseResponse<SingleQuestion> getQuestionById(@PathVariable Integer id){
        SingleQuestion questionById = singleQuestionService.getQuestionById(id);
        if (questionById==null){
            return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR);
        }
        return ResultUtils.success(questionById);
    }

    @GetMapping("/getCount")
    public BaseResponse<Integer> getQuestionCounts(){
        Integer counts = singleQuestionService.getCounts();
        return ResultUtils.success(counts);
    }

}

